package com.marianmedla.jane16.lib;

import java.security.MessageDigest;


/**
 * Basic entity of word in a text.
 * Every word is part of a text ( even just one word is a part of one word text)
 * @author marianmedla
 *
 */
public class Word {
    
	public String text;
	public char[] chtext;
    public int position;
    public String md5; 
    
    public Word(String text, int position, MessageDigest msgdiggest){
    	this.text     = text;
    	this.chtext   = text.toCharArray();
    	this.position = position;
    	//quite important variable. Text (actually phrase) value and its position in content
    	//is combined together and created hash ID in order to have unique idetifier of every 
    	//word in text(content). This way even if text consitst of just all the same words: ( the the the the etc.)
    	//hashes of the words would be different because of position of inividual word in content.
    	byte[] b = (text+position).getBytes();
		md5 = U.toHex( msgdiggest.digest( b ) );
    	
    }
    
    
    
}
